Compare _TCHAR* argv[] entries from command line to _T("paramString")
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2010-05-17T02:58:33Z
Indexed on
2010/05/17
3:00 UTC
Read the original article
Hit count: 427
visual-c++
|visual-studio-2008
I know how to get the parameters from the command line. I also know how to print them out.
The problem I'm having is how to compare the parameters from the argv[] array to a string. The progam runs but never returns a result where the parameter string is equal to the one I'm looking for.
Thanks in advance.
// Testing.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 0; i < argc; i = i + 1)
{
if (argv[i] == _T("find"))
{
wcout << "found at position " << i << endl;
}
else
{
wcout << "not found at " << i << endl;
}
}
return 0;
}
© Stack Overflow or respective owner